package com.hxzy.module.commondity.controller;

import com.github.pagehelper.PageInfo;
import com.hxzy.framework.common.resp.R;
import com.hxzy.module.commodity.api.classifications.req.ClassificationSearchReq;
import com.hxzy.module.commodity.api.classifications.resp.ClassifiedManagementResp;
import com.hxzy.module.commondity.service.ClassifiedManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author wy
 * @Description 分类管理
 * @Date 2024/1/23 16:55
 * @Version 1.0
 */
@Api(tags = "商品管理-商品分类Api")
@RestController
@RequestMapping("/classification")
public class ClassifiedManagementController {

    @Autowired
    private ClassifiedManagementService  classifiedManagementService;

    /**
     * 获得分类列表分页信息
     *
     * @param req 分页封装请求类
     * @return 返回分页列表
     */
    @ApiOperation(value = "分类理表")
    @GetMapping("/getClassifiedPage")
    public R<PageInfo<ClassifiedManagementResp>> getClassifiedPage(@Valid ClassificationSearchReq req) {
        PageInfo<ClassifiedManagementResp> result = this.classifiedManagementService.getClassifiedPage(req);

        return R.success(result);
    }



    /**
     * 根据id 获得分类详细信息
     *
     * @param id 分类id
     * @return 返回分类信息
     */
    @ApiOperation(value = "根据id获得分类详细信息")
    @GetMapping("/getClassified/{id}")
    public R<ClassifiedManagementResp> getClassified( @PathVariable("id") Long id) {
        ClassifiedManagementResp result = this.classifiedManagementService.getClassified(id);
        return R.success(result);
    }

}
